package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.ScCourseClaAttend;
import com.ruoyi.system.domain.StudentApp;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ScCourseCla;
import com.ruoyi.system.service.IScCourseClaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程班级信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-26
 */
@RestController
@RequestMapping("/system/cla")
public class ScCourseClaController extends BaseController
{
    @Autowired
    private IScCourseClaService scCourseClaService;

    /**
     * 查询课程班级信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cla:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScCourseClaAttend scCourseClaAttend)
    {
        startPage();
        List<ScCourseClaAttend> list = scCourseClaService.selectScCourseClaAttendList(scCourseClaAttend);
        return getDataTable(list);
    }
    /**
     * 根据课程名查询班级信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cla:list')")
    @GetMapping("/simpleList")
    public AjaxResult simpleList(@RequestParam  String vall)
    {
        List<ScCourseCla> list = scCourseClaService.selectScCourseClaSimpleList(vall);
        return AjaxResult.success(list);
    }


    /**
     * 导出课程班级信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:cla:export')")
    @Log(title = "课程班级信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScCourseCla scCourseCla)
    {
        List<ScCourseCla> list = scCourseClaService.selectScCourseClaList(scCourseCla);
        ExcelUtil<ScCourseCla> util = new ExcelUtil<ScCourseCla>(ScCourseCla.class);
        util.exportExcel(response, list, "课程班级信息数据");
    }

    /**
     * 获取课程班级信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cla:query')")
    @GetMapping(value = "/{claId}")
    public AjaxResult getInfo(@PathVariable("claId") Long claId)
    {
        return AjaxResult.success(scCourseClaService.selectScCourseClaByClaId(claId));
    }



    /**
     * 新增课程班级信息
     */
    @PreAuthorize("@ss.hasPermi('system:cla:add')")
    @Log(title = "课程班级信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScCourseCla scCourseCla)
    {
        return toAjax(scCourseClaService.insertScCourseCla(scCourseCla));
    }

    /**
     * 修改课程班级信息
     */
    @PreAuthorize("@ss.hasPermi('system:cla:edit')")
    @Log(title = "课程班级信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScCourseCla scCourseCla)
    {
        return toAjax(scCourseClaService.updateScCourseCla(scCourseCla));
    }

    /**
     * 删除课程班级信息
     */
    @PreAuthorize("@ss.hasPermi('system:cla:remove')")
    @Log(title = "课程班级信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{claIds}")
    public AjaxResult remove(@PathVariable Long[] claIds)
    {
        return toAjax(scCourseClaService.deleteScCourseClaByClaIds(claIds));
    }

    /**
     * 查询学生表列表app
     */
    @GetMapping("/ClaListapp")
    public AjaxResult ClaListapp(HttpServletRequest request)
    {
        List<ScCourseCla> scCourseClas = scCourseClaService.selectClaByApp(request);
        return AjaxResult.success(scCourseClas);
    }
}
